package com.itheima.config;

import org.springframework.context.annotation.Bean;
import org.springframework.jdbc.datasource.DataSourceTransactionManager;

import javax.sql.DataSource;

public class TransactionConfig {

    /*
     <bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
        <!--注入连接池:可以通过构造的方式也可以通过set方式注入-->
       <property name="dataSource" ref="dataSource"/>
    </bean>
     */
    @Bean("transactionManager")
    public DataSourceTransactionManager createDataSourceTransactionManager(DataSource dataSource){
        DataSourceTransactionManager dtm=new DataSourceTransactionManager();
        dtm.setDataSource(dataSource);
        return dtm;
    }
}
